package com.mg.axechen.room.dao

import androidx.room.*
import com.mg.axechen.room.bean.User
import io.reactivex.Single

@Dao
interface UserDao {

    /**
     * 普通的获取数据
     */
    @Query("SELECT * FROM user")
    fun getUsers(): MutableList<User>

    /**
     * 和Rxjava联用的获取数据
     */
    @Query("SELECT * FROM user")
    fun getUsersByRxjava() :Single<MutableList<User>>



    @Query("SELECT * FROM user where id=:id")
    fun getUserById(id: Int): User

    @Insert
    fun insertUser(user: User):Long

    @Update
    fun updateUser(user: User):Int

    @Delete
    fun deleteUser(user:User):Int

}